#include <bits/stdc++.h>
using namespace std;
struct Car{
    int l,r;
}t[100005];
vector <int> g[100005];
int T,n,m,ans1,ans2=2e9,dist[100005];
long long L,V,d[100005],v[100005],a[100005],p[100005],maxn;
int f1(int s,long long v1,long long v0,long long x){
    int l=s,r=n,mid;
    while(l<r){
        mid=l+r>>1;
        if(v0*v0+2*x*(p[mid]-d[s])<=v1*v1){
            r=mid;
        }else{
            l=mid+1;
        }
    }
    return l;
}
int f2(int s,long long v1,long long v0,long long x){
    int l=s,r=n,mid;
    while(l<r){
        mid=l+r+1>>1;
        if(1LL*2*x*(p[mid]-d[s])>=v1*v1-v0*v0){
            l=mid;
        }else{
            r=mid-1;
        }
    }
    return l;
}
bool cmp(Car x,Car y){
    if(x.l==y.l){
        return x.r<y.r;
    }else{
        return x.l<y.l;
    }
}
bool vis[100005];
int bfs(int s,int idx){
    vis[s]=1;
    dist[s]=1;
    queue <int> q;
    q.push(s);
    while(!q.empty()){
        int u=q.front();
        q.pop();
        for(int i=0;i<g[u].size();i++){
            int v=g[u][i];
            if(!vis[v]&&dist[u]+1<dist[v]){
                dist[v]=dist[u]+1;
                vis[v]=1;
                q.push(v);
            }
        }
    }
    int minn=0x3f3f3f3f;
    for(int i=1;i<=idx;i++){
        if(t[i].r>=m){
            minn=min(minn,dist[i]);
        }
    }
    return minn;
}
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    scanf("%d",&T);
    while(T--){
        maxn=0;
        ans1=0;
        int idx=0;
        scanf("%d %d %lld %lld",&n,&m,&L,&V);
        for(int i=1;i<=n;i++){
            scanf("%lld %lld %lld",&d[i],&v[i],&a[i]);
        }
        for(int i=1;i<=m;i++){
            scanf("%lld",&p[i]);
            maxn=max(p[i],maxn);
        }
        for(int i=1;i<=n;i++){
            if(d[i]>maxn){
                continue;
            }
            if(a[i]<0){
                if(v[i]<=V){
                    continue;
                }
                int id=lower_bound(p+1,p+1+m,d[i])-p;
                if(v[i]*v[i]+2*a[i]*(p[id]-d[i])>=0&&v[i]*v[i]+2*a[i]*(p[id]-d[i])>V*V){
                    ans1++;
                }
            }else if(a[i]>0){
                if(1LL*2*a[i]*d[i]+V*V-v[i]*v[i]<1LL*2*a[i]*maxn){
                    ans1++;
                }
            }else if(a[i]==0){
                if(v[i]>V&&d[i]<=maxn){
                    t[++idx].l=lower_bound(p+1,p+1+m,d[i])-p;
                    t[++idx].r=m;
                    ans1++;
                }
            }
        }
        printf("%d ",ans1);
        bool flag=0;
        for(int i=1;i<=idx;i++){
            if(t[i].l==1){
                printf("%d\n",m-1);
                flag=1;
            }
        }
        if(!flag){
            printf("0\n");
        }
    }

    return 0;
}
